﻿using CeremonyBackground.Infrastructure.EntityConfigurations;
using CeremonyBackground.Models;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Design;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace CeremonyBackground.Infrastructure
{
    public class BackgroundTasksDbContext : DbContext
    {
        public BackgroundTasksDbContext(DbContextOptions<BackgroundTasksDbContext> options) : base(options)
        {
        }
        public DbSet<BobingUser> BobingUsers { get; set; }

        public DbSet<BobingPrizeResult> BobingPrizeResults { get; set; }

        protected override void OnModelCreating(ModelBuilder builder)
        {
            builder.ApplyConfiguration(new BobingUserEntityTypeConfiguration());
            builder.ApplyConfiguration(new BobingPrizeResultEntityTypeConfiguration());
        }
    }
    public class BackgroundTasksDbContextDesignFactory : IDesignTimeDbContextFactory<BackgroundTasksDbContext>
    {
        public BackgroundTasksDbContext CreateDbContext(string[] args)
        {
            var optionsBuilder = new DbContextOptionsBuilder<BackgroundTasksDbContext>()
                .UseSqlServer("Server=.;Initial Catalog=CeremonyDb;Integrated Security=true");

            return new BackgroundTasksDbContext(optionsBuilder.Options);
        }
    }
}
